home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 March / EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso / earcd / program / amcfp140.lha / AMCAF_Examples / Protracker.AMOS / Protracker.amosSourceCode < prev    next >
AMOS Source Code  |  1996-01-19  |  7KB  |  211 lines

  1. ' ************************************* Commands used: 
  2. ' *                                   * Imploder Load      Blitter Clear 
  3. ' *           Amcaf Examples          * Pt Cia Speed       Turbo Draw
  4. ' *      Protracker Commands V1.2     * Pt Volume          Blitter Fill
  5. ' *      Written by Chris Hodges      * Pt Voice           =Lsstr$ 
  6. ' *                                   * Pt Play            =Lsr
  7. ' ************************************* =Pt Vu 
  8. '                          
  9. ' Hide the mouse cursor, because we need sprite 0. 
  10. Hide 
  11. ' Load some music. 4 Spirits is a tune by Alexander Kunz. Thx for it! :) 
  12. ' Music must be loaded into chipmem, so the banknumber has to be negativ.
  13. ' The music file has been file imploded to save a mere 72 KB of valuable 
  14. ' disk space.
  15.  Extension_8_0EA2 "Data/mod.4spirits",-3
  16. '�Open a 4 colours screen. 
  17. Screen Open 0,320,256,4,Lowres
  18. Curs Off : Flash Off : Paper 0 : Pen 1 : Cls 
  19. ' Copy the sprite palette to the right place.
  20. Get Sprite Palette 
  21. For A=0 To 15 : Colour A+16,Colour(A) : Next 
  22. ' Set screen palette 
  23. Palette $8,$FFF,$8,$FF8
  24. ' Turn on double buffering.
  25. Double Buffer 
  26. Autoback 1
  27. ' Create a nice copper bar.
  28. Set Rainbow 0,1,64,"","",""
  29. For A=0 To 63
  30.   Rain(0,A)=Max(Min(A/3-8,15),0)*$10+Min(A/2,15)*$100+Max(Min(A/2-15,15),0)
  31. Next 
  32. Rainbow 0,0,Y Hard(191),64
  33. ' Dim a field to hold the current vumeter state. 
  34. Dim VU(3)
  35. ' Another field is needed for some boring text.
  36. Dim TXT$(13)
  37. ' TXT$() is filled now filled with text. 
  38. For A=1 To 13
  39.   Read TXT$(A)
  40. Next 
  41. ' Print the speed counter. =Lsstr$ is used to make a formatted string. 
  42. BPM=125
  43. Pen 1 : Locate 0,16 : Print "Current speed: "; Extension_8_0EC8(BPM,3)+" bpm."
  44. Print "To change use cursor left/right."
  45. ' Print the volume control-text. 
  46. VOL=64
  47. Pen 1 : Locate 0,19 : Print "Current volume: "; Extension_8_0EC8(VOL,2)
  48. Print "To change press cursor up/down."
  49. ' Print toggles. To keep it as simple as possible, I reserve a field which 
  50. ' holds the two channel states (on or off), and then look, if the bit
  51. ' is set in the channel mask.
  52. Dim TG$(1)
  53. TG$(0)="Off" : TG$(1)="On "
  54. VOI=%1111
  55. For C=0 To 3
  56.   Locate 0,8+C : Print "Channel";C+1;": "+TG$( Extension_8_093A(VOI,C) and 1)
  57. Next 
  58. Print : Print "Press 1,2,3,4 to toggle channels."
  59. ' Now follow some sprite definitions for the drums.
  60. ' Sorry, but I'm not a graphic artist, and I do apologize the low-quality
  61. ' Sprites :) 
  62. HITHIHAT$="(1,1)(2,1)(1,1)(3,1)(1,2)(2,2)(1,3)(3,3)(1,1)"
  63. OPENHIHAT$="(4,3)(5,3)(1,1)"
  64. HITBASS$="(12,3)(13,3)(14,3)(11,3)"
  65. HITSNARE$="(15,3)(16,3)(17,3)(11,3)"
  66. HITBOTH$="(18,3)(19,3)(20,3)(11,3)"
  67. CLAP$="(7,1)(8,1)(9,1)(10,1)(6,1)"
  68. ' Now display the sprites and assign them to the channels. 
  69. Sprite 0,X Hard(112),Y Hard(64),1
  70. Channel 0 To Sprite 0
  71. Sprite 2,X Hard(128),Y Hard(64),11
  72. Channel 1 To Sprite 2
  73. Sprite 6,X Hard(176),Y Hard(64),6
  74. Channel 2 To Sprite 6
  75. ' Set the music to cia-timing. 
  76.  Extension_8_10F2 BPM
  77. ' Turn up the volume to maximum. 
  78.  Extension_8_10C6 VOL
  79. ' Turn on all voices.
  80.  Extension_8_10D6 VOI
  81. ' And finally, start playing.  
  82.  Extension_8_108E 3
  83. Repeat 
  84.   ' Print out the current song and pattern position: 
  85.   Pen 1
  86.   Locate 0,5 : Print "Song Pos   :"; Extension_8_15DE 
  87.   Print "Pattern Pos:"; Extension_8_15F0 ;" "
  88.   ' Print the instruments and their frequencies
  89.   Pen 1
  90.   For A=0 To 3
  91.     Locate A*10+1,22 : Print Hex$( Extension_8_15FE(A),2); Extension_8_160E(A)/1000;"KHz "
  92.   Next 
  93.   ' Check the keyboard.
  94.   I$=Inkey$
  95.   ' Check for the keys 1 to 4. 
  96.   If I$=>"1" and I$<="4"
  97.     ' Get the channelnumber. I don't use the Val-Function, because it does not 
  98.     ' work correctly when compiled.
  99.     C=Asc(I$)-Asc("1")
  100.     ' Change the bit C in the voice mask.
  101.     Bchg C,VOI
  102.     Pen 1
  103.     Locate 0,8+C : Print "Channel";C+1;": "+TG$( Extension_8_093A(VOI,C) and 1)
  104.      Extension_8_10D6 VOI
  105.   End If 
  106.   ' Has cursor-down been pressed?  
  107.   If I$=Cdown$ and VOL>0
  108.     ' Then make it softer. 
  109.     Dec VOL
  110.     Pen 1 : Locate 16,19 : Print Extension_8_0EC8(VOL,2)
  111.      Extension_8_10C6 VOL
  112.   End If 
  113.   ' Has cursor-up been pressed?
  114.   If I$=Cup$ and VOL<64
  115.     ' Then make it louder. 
  116.     Inc VOL
  117.     Pen 1 : Locate 16,19 : Print Extension_8_0EC8(VOL,2)
  118.      Extension_8_10C6 VOL
  119.   End If 
  120.   ' Has cursor-left been pressed?
  121.   If I$=Cleft$ and BPM>32
  122.     ' Then decrement speed.
  123.     Dec BPM
  124.     Pen 1 : Locate 15,16 : Print Extension_8_0EC8(BPM,3)
  125.      Extension_8_10F2 BPM
  126.   End If 
  127.   ' Has cursor-right been pressed? 
  128.   If I$=Cright$ and BPM<255
  129.     ' Then increase speed. 
  130.     Inc BPM
  131.     Pen 1 : Locate 15,16 : Print Extension_8_0EC8(BPM,3)
  132.      Extension_8_10F2 BPM
  133.   End If 
  134.   ' Clear the old vumeters from the screen.
  135.    Extension_8_1234 0,0,16,190 To 304,256
  136.   For A=0 To 3
  137.     ' Look if there's a new note.
  138.     VU= Extension_8_10E6(A)
  139.     ' Yes? Then set the vumeter to the new value 
  140.     If VU Then VU(A)=VU
  141.     ' Draw two horizontal lines. the vertical lines are not needed.
  142.      Extension_8_1016 A*80+24+VU(A)/4,255-VU(A) To A*80+24+VU(A)/8,255,1
  143.      Extension_8_1016 A*80+57-VU(A)/4,255-VU(A) To A*80+57-VU(A)/8,255,1
  144.     ' Decrement the height of the vumeter bar. 
  145.     VU(A)=Max(VU(A)-2,0)
  146.   Next 
  147.   ' Fill the four vumeters.
  148.    Extension_8_1066 0,0,16,190,304,256
  149.   ' Look if some event has occured.
  150.   P= Extension_8_10B6 
  151.   ' Yes? Then examine the signal.
  152.   If P
  153.     ' Print the value, and fade it out.
  154.     Home : Pen 2 : Print "Pt Signal: ";Hex$(P,2)
  155.     Colour 2,$FF0
  156.     Fade 4,$8,$FFF,$8
  157.     ' If the signal is from 1 to 16, it will be used to print out some text. 
  158.     If P<16
  159.       Pen 3 : Locate 0,3 : Cline : Print TXT$(P)
  160.     End If 
  161.     ' Is it in the range from 16 to 32, it represents one of the drums.
  162.     If P>15 and P<32
  163.       ' Hit the hihat, when signal 16,18 or 20 appeared. 
  164.       If P=16 or P=18 or P=20
  165.         Anim 0,HITHIHAT$ : Anim On 0
  166.       End If 
  167.       ' Open it, if signal 17 was sent.
  168.       If P=17
  169.         Anim 0,OPENHIHAT$ : Anim On 0
  170.       End If 
  171.       ' Bassdrum on 18 and 20
  172.       If P=18 or P=20
  173.         Anim 1,HITBASS$ : Anim On 1
  174.       End If 
  175.       ' Snaredrum on 21
  176.       If P=21
  177.         Anim 1,HITSNARE$ : Anim On 1
  178.       End If 
  179.       ' And both snare and bass on 22
  180.       If P=22
  181.         Anim 1,HITBOTH$ : Anim On 1
  182.       End If 
  183.       ' Clap hands when signal is 19 or 20.
  184.       If P=19 or P=20
  185.         Anim 2,CLAP$ : Anim On 2
  186.       End If 
  187.     End If 
  188.   End If 
  189.   ' Swap screens.
  190.   Screen Swap 
  191.   Wait Vbl 
  192. Until I$=Chr$(27) or Mouse Key
  193.  Extension_8_10A8 
  194. Amal Off 
  195. Sprite Off 
  196. Screen Close 0
  197. Rainbow Del : View : Wait Vbl 
  198. End 
  199. Data "Yeah!!!"
  200. Data "These are AMCAF..."
  201. Data "Protracker commands..."
  202. Data "The text appears..."
  203. Data "in perfect synchro with the music!"
  204. Data "You can control all your effects..."
  205. Data "directly from within the music! Cool!"
  206. Data "Dumdidum... :)))"
  207. Data "Just watch the vumeters... "
  208. Data "And enjoy the music..."
  209. Data "Music by Neurodancer/Abyss."
  210. Data "Sorry, but I'm too lazy to fill in..."
  211. Data "some more commands. Fin!"